/*

	Main Taak class to run everything.

	Main Logic goes here.

*/

#ifndef _TAAK_H
#define _TAAK_H

#include "main.h"
#include <iostream>
#include <cstring>
#include <cctype>
#include "records.h"
#include "command.h"
#include "CommandHistory.h"
#include "Parser.h"

using namespace std;

class Taak{
private:
	FileInterface file;
	CommandHistory commandHistory;
	auto_ptr<Cmd> lastDisplayedCommand;
	Parser parser;
	
	Records taskRecords, initialRecords;
	char buffer[1023];

	//Displays:
	//MainDisplay
	string mainDisplay;
	string mainDisplayTitle;
	//Status:
	string statusDisplay;
	//FeedbackDisplay
	vector<string> feedbackDisplay;
	//Input display - set this if you want to autocomplete. Used for update command.
	string inputDisplay;
	//Records displayed on screen currently.
	Records displayedRecords;

public:


	//Constructor

	Taak(){}
	//Methods
	template <typename T> void myCopyVector(vector<T>& to, vector<T>& from);
	int initialize();
	string userInput(string input);
	string userCharInput(string input);
	string userSuggestionInput(string input, Cmd* command);

	Parser getParser();

	//Execute Functions
	//@author A0105541U
	string executeCommand(auto_ptr<Cmd> cmd);
	string executeAddCommand(CmdAdd* cmd);
	string executeDeleteCommand(CmdDel* cmd);
	string executeDisplayCommand(CmdDisplay* cmd);
	string executeClearCommand(CmdClear* cmd);
	string executeInvalidCommand(CmdInvalid* cmd);
	string executeUpdateCommand(CmdUpdate* cmd);
	string executeDoneCommand(CmdDone* cmd);
	string executeUndoCommand();
	string executeRedoCommand();
	string executeHelpCommand(CmdHelp* cmd);

	string executeSearchCommand(CmdSearch* cmd);
	string executeSortCommand(CmdSort* cmd);
	string executeFilterCommand(CmdFilter* cmd);

	//@author A0105541U
	void displayHomePage();
	void executeCommandHistory(int start, int end);

	//UI Functions
	//@author A0096566M
	string getMainDisplay();
    string getMainDisplayTitle();
	string getStatusDisplay();
	string getInputDisplay();
	vector<string> getFeedbackDisplay();

	void setMainDisplay(string main);
	void setMainDisplayTitle(string title);
	void setStatusDisplay(string status);
	void setFeedbackDisplay(vector<string> feedback);
	void setInputDisplay(string input);
};

#endif
